package com.lgm.ht.controller;

import com.lgm.ht.dto.FruitDTO;
import com.lgm.ht.exception.ParamException;
import com.lgm.ht.service.FruitService;
import com.lgm.ht.utils.ResultModel;
import com.lgm.ht.vo.FruitVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/fruit")
public class FruitController {

    final FruitService fruitService;


    @GetMapping
    public ResultModel<List<FruitVO>> find(FruitDTO fruitDTO){

        //参数校验必须要填写店铺id
        if(fruitDTO.getShopId()==null){
            throw new ParamException("查询水果信息参数错误");
        }
        return fruitService.findByShop(fruitDTO.getShopId(),fruitDTO);
    }
}
